
let contentHeight = 0
let boxHeight = 0
const onScrollBottom = {
  // params: ['param'],
  acceptStatement: false, // 传入的参数不允许是个表达式
  update (dom, params) {
    let callBack
    let offset = 0
    if (!(params.value instanceof Array)) {
      callBack = params.value
    } else {
      [callBack, offset] = params.value
    }
    dom.addEventListener('scroll', function (e) {
      if (this.scrollTop >= contentHeight - boxHeight - offset) {
        callBack && callBack()
      }
    }, false)
  },
  componentUpdated (dom, params) {
    boxHeight = dom.clientHeight
    contentHeight = dom.scrollHeight
  }
}

export default onScrollBottom
